import java.util.*;
public class Lab10Task03 {
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
try {
System.out.print("Enter number of seconds [as an integer]: ");
int s=kb.nextInt();
int[]time=time(s);
System.out.printf("%d seconds = %d hours, %d minutes, and %d seconds",s,time[0],time[1],time[2]);
}
catch(IllegalArgumentException e) {
System.err.print("Error: "+e);
}catch(InputMismatchException e) {
System.err.print("Error: "+e);
}
kb.close();
}
public static int[] time(int s) throws IllegalArgumentException{
int[] time=new int[3];
if(s<0)
throw new IllegalArgumentException();
else {
time[0]=s/3600;
time[1]=(s%3600)/60;
time[2]=(s%3600)%60;
}
return time;
}
}